-
Notifications
You must be signed in to change notification settings - Fork 27
RSDK-6574: Fix use of time_point
#335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
acmorrow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just interested. I'm happy to see this is being fixed!
| const std::string kRDK = "rdk"; | ||
| const std::string kBuiltin = "builtin"; | ||
|
|
||
| using time_pt = std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What motivated the switch from calling it time_point to time_pt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find people do 'using namespace std::chrono' pretty often so I think this would be a name clash with our time_point and std::chrono::time_point<Clock, Duration>
| const std::chrono::nanoseconds nanos(timestamp.nanos()); | ||
| return time_point(std::chrono::duration_cast<std::chrono::system_clock::duration>(seconds) + | ||
| nanos); | ||
| time_pt timestamp_to_time_pt(const google::protobuf::Timestamp& timestamp) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this later be unified with #332 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I look forward to doing so haha
stuqdog
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a question and a nit, otherwise lgtm!
src/viam/sdk/common/utils.hpp
Outdated
| /// std::chrono::time_point<long long, std::chrono::nanoseconds> | ||
| std::chrono::time_point<long long, std::chrono::nanoseconds> timestamp_to_time_pt( | ||
| const google::protobuf::Timestamp& timestamp); | ||
| /// @brief convert a google::protobuf::Timestamp to time_point |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit) s/time_point/time_pt
src/viam/sdk/common/utils.hpp
Outdated
| /// a google::protobuf::Timestamp. | ||
| google::protobuf::Timestamp time_pt_to_timestamp( | ||
| const std::chrono::time_point<long long, std::chrono::nanoseconds>& time_pt); | ||
| /// @brief convert a time_point to a google::protobuf::Timestamp. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit) s/time_point/time_pt
Fixes the incorrect
std::chrono::time_pointtype used throughout the SDK. I have opted to call thisviam::sdk::time_ptso as not to create name clashes withtime_pointfor anyone doingusing namespace std::chrono.